<?php
include_once './model/auth.php';
class LoginController {
	public function invoke () {
		$auth = new Auth();
		if (isset($_POST['username']) and isset($_POST['password'])) {
			$user=$auth->login($_POST['username'],$_POST['password']);
			$id = $_POST['username'];
			if ($user) {
				header('location:./view/home_user.php?id_user='.$id.'');
			} else {
				header('location:./view/login.php');
			}
		} elseif (isset($_GET['logout'])) {
			$auth->logout();
			header('location:./index.php');
		} 
	}
}